package com.android.love.parser;

import java.util.Collections;
import java.util.List;

import android.util.SparseArray;

import com.alibaba.fastjson.JSON;
import com.android.love.util.LogUtil;
import com.android.love.vo.Goods;
import com.android.love.vo.TopGoods;

public class CommentParser extends BaseParser<SparseArray<List>> {
	private static final String TAG = "CommentParser";

	@Override
	public SparseArray<List> parserJson(String jsonStr) {
		SparseArray<List> comments = null;
		if (checkResponse(jsonStr)) {
			// LogUtil.i(TAG, jsonStr);
			String data = jsonObject.getString("data");
			LogUtil.i(TAG, "data---" + data);
			if (data != null) {
				comments = new SparseArray<List>();
				jsonObject = JSON.parseObject(data);
				String recommend = jsonObject.getString("recommend");
				String topic = jsonObject.getString("topic");
				List<Goods> recommends = Collections.emptyList();
				List<TopGoods> topGoods = Collections.emptyList();
				if (!"".equals(recommend)) {
					recommends = JSON.parseArray(recommend, Goods.class);
				}
				if (!"".equals(topGoods)) {
					topGoods = JSON.parseArray(topic, TopGoods.class);
				}
				comments.put(0, recommends);
				comments.put(1, topGoods);
				LogUtil.i(TAG, "data---" + recommends.size());
			}
		}
		// TODO Auto-generated method stub
		return comments;
	}
}
